import java.util.ArrayList;
import java.util.Stack;

class MyQueue{
    Stack<Integer> stack1 = new Stack<>();
    Stack<Integer> stack2 = new Stack<>();
    int[] arr = new int[2];
    int a = arr.length;
    ArrayList<Integer> arrayList = new ArrayList<>(6);
    public void offer(int x ){
        if(stack1.isEmpty()&&stack2.isEmpty()){
            stack1.push(x);
        }else{
            while(!stack1.isEmpty()){
                stack2.push(stack1.pop());
            }
            stack1.push(x);
            while(!stack2.isEmpty()){
                stack1.push(stack2.pop());
            }
        }
    }
    public boolean isEmpty(){
        return stack1.isEmpty();
    }
    public int poll(){
       if(isEmpty()){
           throw new RuntimeException("pop: 栈是空的");
       }
       return stack1.pop();
    }
    public int peek(){
        if(isEmpty()){
            throw new RuntimeException("pop:栈是空的");
        }
        return stack1.peek();
    }
}
public class Queue {
    public static void main(String[] args) {
        MyQueue myQueue = new MyQueue();
        myQueue.offer(1);
        myQueue.offer(2);
        myQueue.offer(3);
        myQueue.offer(4);
        myQueue.offer(5);
        myQueue.offer(6);
        System.out.println(myQueue.poll());
        System.out.println(myQueue.peek());
        System.out.println(myQueue.isEmpty());
        System.out.println(myQueue.poll());
        System.out.println(myQueue.poll());
        System.out.println(myQueue.poll());
        System.out.println(myQueue.poll());
        System.out.println(myQueue.poll());
        System.out.println(myQueue.isEmpty());

    }
}
